<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			
			//1.定义函数
			function hello()
			{
				document.write("hello world <br />");
			
			}
			hello();
			hello();
			function add(a,b)//形参
			{
				
				var result = a+b;
				return result;
				
			}
			document.write("3+5="+add(3,5)+"<br />");//实参
		
			
			//2.匿名函数
			var hello2 = function(){
				document.write("五一假期快乐!<br />");
				
			}
			hello2();
			var add2 = function(a,b){
				var result= a+b;
				return result;
			}
			document.write("3+5="+add2(3,5)+"<br />");
			
			//3.
			var add2 = new Function("a","b","return a+b;");
			document.write("3+5="+add3(3,5)+"<br />");
			//练习
			//1.编写一个行数，传入年月日，计算并返回这天是这一年的第几天
			function count(year,month,day){
			            sum=0;
			            switch(month){
			                case 12:sum+=30;
			                case 11:sum+=31;
			                case 10:sum+=30;
			                case 9:sum+=31;
			                case 8:sum+=31;
			                case 7:sum+=30;
			                case 6:sum+=31;
			                case 5:sum+=30;
			                case 4:sum+=31;
			                case 3:{
			                    if(year%4==0&&year%100!=0||year%400==0)
			                        sum+=29;
			                    else
			                        sum+=28;
			                }
			                case 2:sum+=31;
			            }
			            sum+=day;
			            return sum;
			        }
			        document.write("今天是这一年的第"+count(2024,4,30)+"天")
			
		
		</script>
		
	</body>
</html>
